import grails.test.*

class EventTests extends GrailsUnitTestCase {

  def now = new Date()
  def startNearlyNow = new Date(now.time + 7000)
  def endNearlyNow = new Date(now.time + 3607000)
  def startFuture = new Date(now.time + 9999990000)
  def endFuture = new Date(now.time + 9999999999)

  UserAccount u1, u2
  Event e1, e2, e3, e4

  protected void setUp() {
    super.setUp()
    u1 = new UserAccount(firstName: "Dale", lastName: "Manthei", email: "d@g.com", password: "pass")
    u2 = new UserAccount(firstName: "Alison", lastName: "Manthei", email: "a@g.com", password: "pass")
    e1 = new Event(name: "Event1", description: "E1-D1", location: "E1-L1", startDate: startNearlyNow, endDate: endNearlyNow, administrator: u1)
    e2 = new Event(name: "Event2", description: "E2-D2", location: "E2-L2", startDate: startFuture, endDate: endFuture, administrator: u2)
    e3 = new Event(name: "Event1", description: "E1-D1", location: "E1-L1", startDate: startNearlyNow, endDate: endNearlyNow, administrator: u1)
    e4 = e1
    assertNotNull u1
    assertNotNull u2
    assertNotNull e1
    assertNotNull e2
    assertNotNull e3
    assertNotNull e4
  }

  protected void tearDown() {
    super.tearDown()
  }

  void testEqualsTheSame() {
    assertTrue e1.equals(e3)
    assertTrue e1.equals(e4)
  }

  void testEqualsNotSame() {
    assertTrue !e1.equals(e2)
    assertTrue !e1.equals(u2)    
  }


  void testHash() {
    println e1.hashCode().toString()
    assertTrue e1.hashCode()!= 0
  }

}
